{include file='ebcms@common/header' /}
<div class="container-fluid">
    <div class="row">
        {php}
            $cate = \think\Db::name('extend') -> find(input('id'));
            $data = \think\Db::name('extendfield') -> where('category_id',input('id')) -> order('sort desc,id asc') -> select();
            $data = \ebcms\Tree::group($data);
        {/php}
        <div class="col-md-12">
            <h3>
                <span>{$cate.title}</span>
                <a href="{:url('extendfield/add',['group'=>'','category_id'=>$cate['id']])}"><span class="glyphicon glyphicon-plus"></span></a>
            </h3>
            <div class="table-responsive">
                <table class="table table-bordered table-hover table-ebcms">
                    <tbody>
                        <tr>
                            <th style="width:80px;">排序</th>
                            <th style="width:170px;">操作</th>
                            <th>标题</th>
                            <th>字段</th>
                        </tr>
                        {foreach name='data' item='items' key='group'}
                            <tr>
                                <th colspan="2">{$group}</th>
                                <th colspan="2">
                                    <a href="{:url('extendfield/add',['group'=>$group,'category_id'=>$cate['id']])}" class="btn btn-primary btn-sm">添加</a>
                                </th>
                            </tr>
                            {foreach name='items' item='vo'}
                                <tr>
                                    <td>
                                        <input value="{$vo.sort}" class="form-control input-sm ebcms-change" url="{:url('extendfield/resort')}" data-id="{$vo.id}">
                                    </td>
                                    <td>
                                        {eq name='vo.status' value='1'}
                                        <button type="button" class="btn btn-primary btn-sm ebcms-do" url="{:url('extendfield/status')}" data-ids='{$vo.id}' data-value='0'><span class="glyphicon glyphicon-ok-sign"></span></button>
                                        {else/}
                                        <button type="button" class="btn btn-warning btn-sm ebcms-do" url="{:url('extendfield/status')}" data-ids='{$vo.id}' data-value='1'><span class="glyphicon glyphicon-ban-circle"></span></button>
                                        {/eq}
                                        <button type="button" class="btn btn-primary btn-sm ebcms-do" url="{:url('extendfield/delete')}" data-ids='{$vo.id}' confirm="删除后不可恢复，确定删除？"><span class="glyphicon glyphicon-remove"></span></button>
                                        <a href="{:url('extendfield/edit?id='.$vo['id'])}" class="btn btn-primary btn-sm"><span class="glyphicon glyphicon-pencil"></span></a>
                                        <a href="{:url('extendfield/edit?do=config&id='.$vo['id'])}" class="btn btn-primary btn-sm"><span class="glyphicon glyphicon-wrench"></span></a>
                                    </td>
                                    <td>{$vo.title}</td>
                                    <td>{$vo.name}</td>
                                </tr>
                            {/foreach}
                        {/foreach}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
{include file='ebcms@common/footer' /}